package com.niodata.dp.task.entity;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.niodata.dp.task.TaskOptions;
import java.util.Date;
import java.util.List;

/**
 * task specification,workflow、exec plan string.
 */
public class TaskInfo {

  private String name;
  private String appId;
  private String appName;
  private int seqId;
  private String taskId;
  private int azProjectId;
  private Date createTime;
  private Date modifyTime;
  private String creator;
  @JsonIgnore
  private List<JobInfo> jobInfoList;
  private boolean scheduled = false;
  private String scheduleCron;
  private Date scheduledTime;
  private String description;
  private Long ownerId;
  private String ownerType;
  private boolean bindExecutor;
  private int executorId;
  private TaskParams params;
  private TaskOptions options;
  private boolean template;
  private TaskAlertSetting alertSetting;

  private boolean delProtection;

  public boolean isTemplate() {
    return template;
  }

  public void setTemplate(boolean template) {
    this.template = template;
  }

  public TaskParams getParams() {
    return params;
  }

  public void setParams(TaskParams params) {
    this.params = params;
  }

  public int getSeqId() {
    return seqId;
  }

  public void setSeqId(int seqId) {
    this.seqId = seqId;
  }

  public String getDescription() {
    return description;
  }

  public void setDescription(String description) {
    this.description = description;
  }

  public String getName() {
    return name;
  }

  public void setName(String name) {
    this.name = name;
  }

  public String getTaskId() {
    return taskId;
  }

  public void setTaskId(String taskId) {
    this.taskId = taskId;
  }

  public int getAzProjectId() {
    return azProjectId;
  }

  public void setAzProjectId(int azProjectId) {
    this.azProjectId = azProjectId;
  }

  public Date getCreateTime() {
    return createTime;
  }

  public void setCreateTime(Date createTime) {
    this.createTime = createTime;
  }

  public String getCreator() {
    return creator;
  }

  public void setCreator(String creator) {
    this.creator = creator;
  }

  public List<JobInfo> getJobInfoList() {
    return jobInfoList;
  }

  public void setJobInfoList(List<JobInfo> jobInfoList) {
    this.jobInfoList = jobInfoList;
  }

  public boolean isScheduled() {
    return scheduled;
  }

  public void setScheduled(boolean scheduled) {
    this.scheduled = scheduled;
  }

  public boolean isDelProtection() {
    return delProtection;
  }

  public void setDelProtection(boolean delProtection) {
    this.delProtection = delProtection;
  }

  public String getScheduleCron() {
    return scheduleCron;
  }

  public void setScheduleCron(String scheduleCron) {
    this.scheduleCron = scheduleCron;
  }

  public Date getScheduledTime() {
    return scheduledTime;
  }

  public void setScheduledTime(Date scheduledTime) {
    this.scheduledTime = scheduledTime;
  }

  public Date getModifyTime() {
    return modifyTime == null ? createTime : modifyTime;
  }

  public void setModifyTime(Date modifyTime) {
    this.modifyTime = modifyTime;
  }

  /**
   * strict properties equals.
   *
   * @param task task info
   * @return equals
   */
  public boolean isConfEquals(TaskInfo task) {
    if (this == task) {
      return true;
    }
    if (task == null || getClass() != task.getClass()) {
      return false;
    }
    TaskInfo other = (TaskInfo) task;
    if (azProjectId != other.azProjectId) {
      return false;
    }

    if (jobInfoList == null) {
      if (other.jobInfoList != null) {
        return false;
      }
    } else if (!jobInfoList.equals(other.jobInfoList)) {
      return false;
    }

    if (scheduleCron == null) {
      if (other.scheduleCron != null) {
        return false;
      }
    } else if (!scheduleCron.equals(other.scheduleCron)) {
      return false;
    }

    if (taskId == null) {
      if (other.taskId != null) {
        return false;
      }
    } else if (!taskId.equals(other.taskId)) {
      return false;
    }
    return true;
  }

  public boolean isBindExecutor() {
    return bindExecutor;
  }

  public void setBindExecutor(boolean bindExecutor) {
    this.bindExecutor = bindExecutor;
  }

  public int getExecutorId() {
    return executorId;
  }

  public void setExecutorId(int executorId) {
    this.executorId = executorId;
  }

  public Long getOwnerId() {
    return ownerId;
  }

  public void setOwnerId(Long ownerId) {
    this.ownerId = ownerId;
  }

  public String getOwnerType() {
    return ownerType;
  }

  public void setOwnerType(String ownerType) {
    this.ownerType = ownerType;
  }

  public String getAppId() {
    return appId;
  }

  public void setAppId(String appId) {
    this.appId = appId;
  }

  public String getAppName() {
    return appName;
  }

  public void setAppName(String appName) {
    this.appName = appName;
  }

  public TaskOptions getOptions() {
    return options;
  }

  public void setOptions(TaskOptions options) {
    this.options = options;
  }

  public TaskAlertSetting getAlertSetting() {
    return alertSetting;
  }

  public void setAlertSetting(TaskAlertSetting alertSetting) {
    this.alertSetting = alertSetting;
  }
}
